package com.basic.business.quantityReceived.controller;

import com.basic.business.mat.domain.TMatMgmt;
import com.basic.business.quantityReceived.domain.TQuantityReceived;
import com.basic.business.quantityReceived.service.ITQuantityReceivedService;
import com.basic.business.wholeIndicators.domain.TWholeStationIndicators;
import com.basic.common.annotation.FileExport;
import com.basic.common.annotation.Log;
import com.basic.common.core.controller.BaseController;
import com.basic.common.core.domain.AjaxResult;
import com.basic.common.core.page.TableDataInfo;
import com.basic.common.enums.BusinessType;
import com.basic.common.utils.easyExcel.EasyExcelUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * 接取数量Controller
 *
 * @author ruize
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/business/received")
public class TQuantityReceivedController extends BaseController
{
    @Resource
    private ITQuantityReceivedService tQuantityReceivedService;

    /**
     * 查询接取数量列表
     */
    @PreAuthorize("@ss.hasPermi('business:received:list')")
    @GetMapping("/list")
    public TableDataInfo list(TQuantityReceived tQuantityReceived)
    {
        startPage();
        List<TQuantityReceived> list = tQuantityReceivedService.selectList(tQuantityReceived);
        return getDataTable(list);
    }

    @GetMapping("/selectUserRole")
    public AjaxResult selectUserRole()
    {
        List<Map<String, Object>> list = tQuantityReceivedService.selectUserRole();
        return success(list);
    }

    /**
     * 导出接取数量列表
     */
    @PreAuthorize("@ss.hasPermi('business:received:export')")
    @Log(title = "接取数量", businessType = BusinessType.EXPORT)
    @FileExport(fileName = "接取数量数据.xlsx")
    @PostMapping("/export")
    public String export(TQuantityReceived tQuantityReceived) throws IOException
    {
        List<TQuantityReceived> list = tQuantityReceivedService.getList(tQuantityReceived);
        return EasyExcelUtils.excelExport(TQuantityReceived.class,"全站推指标数据数据", list);
    }

    /**
     * 获取接取数量详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:received:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tQuantityReceivedService.get(id));
    }

    /**
     * 新增接取数量
     */
    @PreAuthorize("@ss.hasPermi('business:received:add')")
    @Log(title = "接取数量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TQuantityReceived tQuantityReceived)
    {
        return toAjax(tQuantityReceivedService.insert(tQuantityReceived));
    }

    /**
     * 修改接取数量
     */
    @PreAuthorize("@ss.hasPermi('business:received:edit')")
    @Log(title = "接取数量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TQuantityReceived tQuantityReceived)
    {
        return toAjax(tQuantityReceivedService.update(tQuantityReceived));
    }

    /**
     * 删除接取数量
     */
    @PreAuthorize("@ss.hasPermi('business:received:remove')")
    @Log(title = "接取数量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tQuantityReceivedService.deleteByIds(ids));
    }
}
